\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ul0\fs24 swapdisk other than on 40\
\i \
\i0 Q: Does anyone have any experience setting up an alternative swap device? I'm booting off the Ethernet and want to swap to a 330. Do I just label my 330 as swapdisk?\
\
A: Following is the answer, and lots of background. The quick answer, though: yes, call it swapdisk and things (mostly) work, with only a little more to do, like modifying swaptab(5) and fstab(5).\
\
When the system boots up, it runs
\f2 /etc/rc
\f0 , a shell script. The
\f2 rc
\f0 script (rc stands for “Run Control”) is what does “multi-user start-up.” One thing to recognize is that in single-user land, the virtual memory system is turned off: no paging is done. The paging system is fired up during multi-user start-up. (Now, one might think this is a big limitation on single-user mode's usefulness. Not really: we have a minimum 8MB of core, so without the Window Server and the Workspace Manager, there's lots of room in which to play.)\
\
In the “Goode Olde Dayes,” the system would (typically) page to the file\
\
\f2 /private/vm/swapfile
\f0 \
\
Typically, because it's actually configurable, in
\f2 /etc/swaptab
\f0 (yes, there's a man page: section 5). The
\f2 mach_swapon(8)
\f0 command, invoked in
\f2 rc
\f0 , reads
\f2 swaptab
\f0 and enables paging on the specified files. And that was that, mostly.\
\
Now we have the possibility of the swapdisk, which we want to use automatically. So, another
\f2 rc
\f0 script was written:
\f2 rc.swap
\f0 handles the determination of whether there's a swapdisk present, and, if so, turning on paging to it. To do this,
\f2 rc.swap
\f0 looks in
\f2 /etc/fstab
\f0 , trying to find a file system called
\f2 /private/swapdisk
\f0 which should be mounted. (
\fs22 NOTE
\fs24 : this information is
\i\fs22 NOT
\i0\fs24 obtained from NetInfo!) If it finds one, it looks at the device's label, to see if the device is called swapdisk. If not, it ignores the disk; if so, it continues on to enable paging on that disk. (See the
\f2 checkswap
\f0 (8) command for yet more details.)\
\
Specifically, to enable paging, rc.swap first mounts the file system. Then, it ensures that the file\
\
\f2 /private/swapdisk/vm/swapfile
\f0 \
\
exists, and invokes
\f2 mach_swapon
\f0 to turn on paging — turning it on
\b explicitly
\b0 to this file, and
\b not
\b0 consulting
\f2 swaptab
\f0 . In addition,
\f2 rc.swap
\f0 ensure that
\f2 /tmp
\f0 references a directory on the swapdisk.\
\
None of this changes what
\f2 rc
\f0 itself does, though. It still invokes
\f2 mach_swapon
\f0 , just like in the Goode Olde Dayes. This will enable paging to two files (based on the standard configuration of
\f2 swaptab
\f0 ):\
\
\f2 /private/swapdisk/vm/swapfile
\f0 \
\f2 /private/vm/swapfile
\f0 \
\
This might seem like A Good Thing, but it isn't. Last we knew, there was a (minor?) bug which prevented using multiple swapfiles successfully. (The bug is that if a mapped file spans swapfile boundaries, not-completely-predictable things can happen. To tickle the bug, though, the primary swapfile must fill up first.) Should be benign, really.\
\
So, back to the original question! Here it is again:\
\
\i Q: Does anyone have any experience setting up an alternative swap device? I'm booting of the Ethernet and want to swap to a 330. Do I just label my 330 as swapdisk?\
\i0 \
Yes, label the 330 as
\b swapdisk
\b0 , and all should be fine. Note that everything after the first eight characters in the disk name is ignored, so swapdisk1 or swapdiskFuBar is supposed to work, too. But, please please please don't then boot off the 330 after having used it for a swapdisk:
\f2 /tmp
\f0 will be screwed up. Remember that
\f2 rc.swap
\f0 puts points
\f2 /tmp
\f0 to the swapdisk? Well, you end up with
\f2 /tmp
\f0 referencing (eventually)\
\
\f2 /private/swapdisk/tmp\
\
\f0 (We say “eventually” because there are multiple levels of symbolic links). So at best, a bit of mucking around, perhaps in
\f2 rc
\f0 , will be needed to set things back to rights. If you're always going to boot off the network, then\